package by.exposit.controller;

import by.exposit.domain.Donate;
import by.exposit.domain.Pocket;
import by.exposit.domain.User;
import by.exposit.service.DonateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

 @Controller
@RequestMapping("/donate")
 public class PocketController {
    @Autowired
    DonateService  donateService;

    @RequestMapping(value =  "/new", method = RequestMethod.POST)
    public ModelAndView Pocket(Pocket pocket, User user, long money){
         ModelAndView modelAndView = new ModelAndView();
         donateService.saveDonate(new Donate(pocket,user,money));
         modelAndView.setViewName("welcome");
         return modelAndView;
      }

}
